package com.ihg.hiex.admin.entity.search;

import java.util.Map;

import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

public class AssessorSearch implements QueryBuilder {

    private String name;

    private String email;

    private String telephone;

    private String mobile;

    private String hotelName;

    private String subregion;

    private String title;

    /**
     * filter
     */
    private QueryFilter filter;

    /**
     * order
     */
    private QueryOrder order;

    public AssessorSearch() {

        order = new QueryOrder().add("lastModifyTime", "DESC");
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(
     * boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
        if (filter == null || refresh) {

            filter = new QueryFilter().addLike("name", name)
                                      .addLike("email", email)
                                      .addLike("telephone", telephone)
                                      .addLike("mobile", mobile)
                                      .addLike("hotelName", hotelName)
                                      .addLike("subregion", subregion)
                                      .addLike("title", title);
        }
        return filter;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
    public QueryOrder getOrder() {

        return order;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {

        String sentence = "FROM Assessor WHERE disabled = false" + getPreparedFilter(false).clauseSentence()
                + order.sentence();

        return sentence;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {

        return getPreparedFilter(false).parameters();
    }

    /**
     * @return
     */
    public QueryFilter getFilter() {
        return filter;
    }

    /**
     * @param order
     */
    public void setOrder(QueryOrder order) {
        this.order = order;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the telephone
     */
    public String getTelephone() {
        return telephone;
    }

    public String getMobile() {
        return mobile;
    }

    /**
     * @return the hotelName
     */
    public String getHotelName() {
        return hotelName;
    }

    /**
     * @return the subregion
     */
    public String getSubregion() {
        return subregion;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param email
     *            the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param telephone
     *            the telephone to set
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    /**
     * @param hotelName
     *            the hotelName to set
     */
    public void setHotelName(String hotelName) {
        this.hotelName = hotelName;
    }

    /**
     * @param subregion
     *            the subregion to set
     */
    public void setSubregion(String subregion) {
        this.subregion = subregion;
    }

    /**
     * @param title
     *            the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

}
